home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / utils1 / adjramd.arj / ADJRAM.DOC < prev    next >
Text File  |  1993-09-18  |  41KB  |  845 lines

  1.         
  2.  
  3.  
  4.                           ADJRAM -- Adjustable RAM Disk
  5.                                      
  6.                                 by Gary Cramblitt
  7.  
  8.                                    Version 3.0
  9.  
  10.         (c) Copyright 1986 by Gary Cramblitt.  All rights reserved.
  11.             Permission is granted to copy and use this software for
  12.             non-commercial purposes only.  
  13.  
  14.             NOTICE:  This program is provided on an "as is" basis 
  15.             without warranty of any kind, expressed or implied, 
  16.             including but not limited to the implied warranties of 
  17.             mercantability and fitness for a particular purpose.  The 
  18.             entire risk as to quality and performance of this program is 
  19.             with you, the user.  Should the program prove defective, you 
  20.             assume the entire cost of all necessary repair, servicing, 
  21.             or correction.  In no event will the author be liable to you 
  22.             for any damages, including any lost profits, lost savings, 
  23.             or other incidental or consequential damages arising out of 
  24.             the use or inability to use this program.
  25.  
  26.  
  27.         This program, although copyrighted, may be freely copied and 
  28.         used, so long as it is not used for commercial purposes.  It is 
  29.         NOT shareware or user-supported software.  You are not expected 
  30.         to make a donation to the author for using this program.  Enjoy 
  31.         -- and try to do the same for others some day.  
  32.  
  33.  
  34.         What Is ADJRAM?
  35.         ---------------
  36.         ADJRAM is a RAM disk program.  Sometimes, RAM disks are called 
  37.         "virtual disks" like the VDISK supplied with PC-DOS.  Sometimes 
  38.         they are called "memory disks" like MEMBRAIN.  Whatever you call 
  39.         it, a RAM disk is a program that makes a section of the Random 
  40.         Access Memory (RAM) of your computer look like a floppy disk 
  41.         drive to DOS.  The advantage is that RAM is many hundreds of 
  42.         times faster than a floppy disk -- even faster than a hard disk.  
  43.  
  44.         Why use ADJRAM, when you already have VDISK or MEMBRAIN or some 
  45.         other RAM disk?  Because ADJRAM allows you to vary the size of 
  46.         the RAM disk without rebooting, and without loss of existing 
  47.         data stored in the RAM disk.  For example, you can start out 
  48.         with 64K of your memory allocated for the RAM disk, expand it 
  49.         later to 320K, copy a document file of 60K to the RAM disk, and 
  50.         still later reduce the RAM disk capacity back down to 128K -- 
  51.         without losing your document file.
  52.  
  53.         ADJRAM is ideal for those who do not have a hard disk.
  54.  
  55.  
  56.         Requirements
  57.         ------------
  58.         ADJRAM is designed to run under MS-DOS version 2 or greater.  It 
  59.         has been tested on the following machines:
  60.  
  61.              1.  Zenith Z100 under MS-DOS version 2.21
  62.              2.  Zenith Z171 (an IBM PC compatible) under MS-DOS version 
  63.                  2.11
  64.              3.  KayPro 16 also under MS-DOS 2.11
  65.              4.  Zenith Z158 (another IBM PC compatible) under MS-DOS 
  66.                  3.1 with a 2 Mbyte JRAM 3 card 
  67.  
  68.         It is the author's belief that it will run under PC-DOS version 
  69.         2 or higher, but this has not been tested.  It requires 
  70.         approximately 10K bytes of disk space.  Memory usage is, of 
  71.         course, a function of the RAM disk's size, but it requires a 
  72.         minimum of 65K free RAM.
  73.  
  74.  
  75.         Installation
  76.         ------------
  77.         Note: If you have a computer with LOTUS/INTEL/Microsoft Expanded 
  78.               Memory and you want ADJRAM to use the Expanded Memory, 
  79.               please read the section below entitled "Expanded Memory 
  80.               Support" before you install ADJRAM.  
  81.  
  82.         Copy the following files to your boot disk: 
  83.  
  84.              AMDISK.DVD
  85.              ADJRAM.EXE
  86.  
  87.         Edit your CONFIG.SYS file and place the following line in it:
  88.  
  89.              device = amdisk.dvd
  90.  
  91.         Reboot your computer.  If all goes well, you should see the 
  92.         following message appear near the beginning of your boot 
  93.         sequence:
  94.  
  95.              AMDISK v3.0 (c) Copyright 1986 by Gary Cramblitt--
  96.                     Initialized as disk C:
  97.  
  98.         The disk drive letter will vary according to your system 
  99.         configuration.  Remember that drive letter, since it is that 
  100.         disk which is your RAM disk.  
  101.  
  102.         If you use any memory resident programs, such as Sidekick (a 
  103.         trademark of Borland International), load them before attempting 
  104.         to change the size of the RAM disk (as explained in the next 
  105.         section).  
  106.         
  107.                                                         
  108.         Using the RAM Disk
  109.         ------------------
  110.         The RAM disk is used just like any floppy disk drive.  You can 
  111.         copy files to or from it, create directories on it, erase files, 
  112.         etc.  You may NOT do the following things with the RAM disk:
  113.         
  114.              1.  You may not FORMAT the RAM disk.
  115.              2.  You may not DISKCOPY from or to the RAM disk.
  116.              3.  You may not run SYS against the RAM disk.
  117.              4.  You may not boot from the RAM disk.
  118.              5.  You may not use any program on the RAM disk that 
  119.                  accesses the disk controller circuitry directly.  Some 
  120.                  anti-copy protection programs fall into this category.
  121.              6.  You may not use any program that depends upon IBM
  122.                  standard disk media codes.  One such program is CHKDSK.  
  123.                  My version of CHKDSK will report that my RAM disk is a 
  124.                  non-standard format and ask me if I wish to continue.  
  125.                  If I say yes, everything works normally thereafter.
  126.  
  127.         Restrictions 1 through 5 are generally true of any RAM disk.  
  128.         Restriction 6 is unique to the Adjustable RAM Disk because it 
  129.         uses a non-standard disk media code.  This shouldn't cause great 
  130.         hardship though.  
  131.  
  132.         Also, keep in mind that anything stored in the RAM disk can 
  133.         potentially be lost.  For example, should your power fail and 
  134.         you don't have an Uninterruptible Power Source (UPS), then 
  135.         everything in the RAM disk will be lost.  If you reboot (by 
  136.         pressing CTRL-ALT-DEL for example), the contents of the RAM disk 
  137.         are lost.  It is a good idea to periodically copy important 
  138.         files to a more permanent medium, such as floppy disk.  
  139.  
  140.         The RAM disk defaults to a size of 64K bytes when you first boot 
  141.         the system.  The ADJRAM program is used to change this size.  
  142.         For example, to increase the size of the RAM disk by 64K bytes, 
  143.         enter the following command to the DOS prompt: 
  144.  
  145.              ADJRAM C: +64
  146.  
  147.         The spaces after "ADJRAM" and after "C:" are required.  The 
  148.         drive letter (C:) will vary according to your system's 
  149.         configuration.  Use whatever letter was displayed by AMDISK when 
  150.         you booted the system.
  151.         
  152.         When ADJRAM is run, you should see something like this displayed 
  153.         on your screen: 
  154.  
  155.              Adjust Memory Disk (c) Copyright 1986 by Gary Cramblitt
  156.              Drive C:   Total Size: 64K        Free Space: 61K
  157.                       Desired Size: 128K    Desired Change: 64K
  158.              Allocating new 32K memory block #1
  159.              Allocating new 32K memory block #2
  160.  
  161.                         Memory Block Table
  162.              Block #      Paragraph      Size(sectors)
  163.              --------     ---------      -------------
  164.                 0            604              128
  165.                 1           26A9               64
  166.                 2           2EAA               64
  167.  
  168.         The drive letter displayed will vary, as I've already explained.  
  169.         The exact paragraph numbers will also vary according to your 
  170.         system configuration and whatever other software is loaded.
  171.  
  172.         ADJRAM always increments its size in 32K junks, called "memory 
  173.         blocks".  The change you specify is always rounded up to the 
  174.         next closest multiple of 32.  In the example above, two new 32K 
  175.         memory blocks are created for the additional 64K of space.  The 
  176.         Memory Block Table is displayed for your information only.  For 
  177.         the most part, you can ignore it.  
  178.  
  179.         You must have sufficient free memory to allocate the additional 
  180.         size.  Run CHKDSK if you are unsure about how much free memory 
  181.         you have.
  182.  
  183.         You can also shrink the RAM disk.  For example, the following 
  184.         command would decrease the size of the RAM disk by 32K: 
  185.  
  186.              ADJRAM C: -32
  187.  
  188.         You must have sufficient free space in the RAM disk in order to 
  189.         shrink it.  To find out how much free space you have in the RAM 
  190.         disk, enter the following command:
  191.  
  192.              ADJRAM C:
  193.  
  194.         Notice how there is no size parameter.  The program will display 
  195.         the current size and free space of the RAM disk.  If you have 
  196.         insufficient space, you must erase enough files to get 
  197.         sufficient space.  Then enter your ADJRAM command again.  
  198.  
  199.         You can not shrink the RAM disk to less than 64K.
  200.  
  201.         Instead of giving the size of the RAM disk as a plus or minus 
  202.         figure, you can specify the desired size of the RAM disk like 
  203.         this:
  204.  
  205.              ADJRAM C: 320
  206.  
  207.         This command will set the RAM disk to 320K.  If it is currently 
  208.         larger than 320K, it will shrink it down to 320K (provided there 
  209.         is sufficient free space to do so).  If it is currently smaller 
  210.         than 320K, it will expand the size to 320K by allocating new 
  211.         memory blocks.  Remember that ADJRAM will round the figure you 
  212.         specify to the next higher multiple of 32.  
  213.  
  214.         If you want to adjust the size of the memory disk so that it has 
  215.         200K of free space, enter a command like this:
  216.  
  217.              ADJRAM C: f200
  218.  
  219.         Notice the letter "f" in front of the size.  This command will 
  220.         expand or shrink the RAM disk so as to ensure there is about 
  221.         200K of free space IN THE RAM DISK.  
  222.  
  223.         If you want to ensure there is at least 128K of free space in 
  224.         the RAM disk, enter a command like this:
  225.  
  226.              ADJRAM C: m128
  227.  
  228.         Notice the letter "m" in front of the size.  This command will 
  229.         never shrink the RAM disk, but it may expand it to make sure 
  230.         there is a minimum of 128K of free space.  This form of the 
  231.         command is particularly handy within batch files to make sure 
  232.         the RAM disk is large enough to hold a file before it is copied 
  233.         into the RAM disk.
  234.  
  235.  
  236.         Online Help
  237.         -----------
  238.         If you can't remember the format for all these commands, fear 
  239.         not.  Simply enter 
  240.  
  241.              ADJRAM
  242.  
  243.         and it will display a help message showing the formats described 
  244.         above.
  245.  
  246.  
  247.         Hint for Floppy Disk Systems
  248.         ----------------------------
  249.         If you do not have a hard disk, soon after booting your 
  250.         computer, copy file ADJRAM.EXE to the RAM disk, for example:
  251.  
  252.              COPY A:ADJRAM.EXE C:
  253.  
  254.         You can then modify the size of the RAM disk at any time 
  255.         thereafter without needing the boot disk.  Just put the RAM disk 
  256.         drive letter in front of any ADJRAM commands.  For example:
  257.  
  258.              C:ADJRAM C: -32
  259.  
  260.         You can put the COPY command into your AUTOEXEC.BAT file.
  261.  
  262.  
  263.         Expanded Memory Support
  264.         -----------------------
  265.         ADJRAM provides limited support for LOTUS/INTEL/Microsoft 
  266.         Expanded Memory (EMS version 3.2 compatible).  
  267.  
  268.         If you have a computer with LOTUS/INTEL/Microsoft Expanded 
  269.         Memory and you want ADJRAM to use that memory, the installation 
  270.         is a little different.  Instead of copying ADJRAM.EXE to your 
  271.         boot disk, copy file ADJRAMEM.EXE and then rename it to 
  272.         ADJRAM.EXE.  The rest of the installation is the same as was 
  273.         described before.  
  274.         
  275.         If you want the program to create new memory blocks in 
  276.         LOTUS/INTEL/Microsoft Expanded Memory, add a "/E" option, like 
  277.         this:
  278.  
  279.              ADJRAM C: +32 /E
  280.  
  281.         This command will expand the memory disk by 32K.  The additional 
  282.         32K memory block will be created within LOTUS/INTEL/Microsoft 
  283.         Expanded Memory.  If ADJRAM ends up shrinking the RAM disk, the 
  284.         "/E" switch is meaningless.  Remember that ADJRAM will always 
  285.         shrink the RAM disk by freeing memory blocks in reverse of the 
  286.         order inwhich they were created.  
  287.  
  288.         The version of ADJRAM that supports Expanded Memory can not be 
  289.         used in conjunction with the version that does not support it.  
  290.         Don't get them mixed up.  Use ADJRAMEM.EXE (renamed to 
  291.         ADJRAM.EXE) or use ADJRAM.EXE -- but not both.
  292.         
  293.         There are a couple of restrictions with the Expanded Memory 
  294.         version of ADJRAM.  First, some Expanded Memory systems have a 
  295.         limited number of Expanded Memory handles.  ADJRAM uses one 
  296.         handle for each 32K Memory Block it creates.  This means that 
  297.         one megabyte of RAM disk from Expanded Memory will use up 32 
  298.         handles.  The Expanded Memory Manager provided with the JRAM 3 
  299.         board I tested (JPAGER) had only 32 handles, so creating a one 
  300.         megabyte RAM disk used up all of the EM handles.  
  301.  
  302.         Even if you have lots of EM handles, the largest RAM disk that 
  303.         can be created using Expanded Memory is 2016K or about 2 
  304.         Megabytes.  EMS supports up to 8 Megabytes.  If you want more 
  305.         RAM disk, add additional "device = amdisk.dvd" statements to 
  306.         your CONFIG.SYS file.  This will create additional RAM disks 
  307.         with different drive letters.  
  308.  
  309.         I'm looking for feedback from users on this feature.  Is it 
  310.         worth it?  I suspect that most people who own Expanded Memory 
  311.         boards prefer to use the RAM disk software that comes with those 
  312.         boards.  Right now, fixing these problems doesn't seem 
  313.         worthwhile.  If I'm wrong about that, please let me know.
  314.  
  315.         If you think the Expanded Memory support is needed, what size 
  316.         increment should it use?  128K? 256K?
  317.  
  318.         The Expanded Memory support in this version of ADJRAM was coded 
  319.         based on information from the book "Advanced MS-DOS" by Ray 
  320.         Duncan.  The code was tested on a Zenith Z158 with a 2 Mbyte 
  321.         JRAM 3 memory board installed (JBOOT and JPAGER loaded).  I 
  322.         don't own a computer with Expanded Memory, so this part of the 
  323.         program is the least tested.  Please be cautious until you've 
  324.         had time to thoroughly check out the program -- and let me know 
  325.         if you encounter difficulty.  
  326.  
  327.         
  328.         Error Messages
  329.         --------------
  330.         Any time that an error occurs, the phrase "Error -- " is 
  331.         displayed, followed by one of the following messages.  In 
  332.         addition, the program sometimes displays the help message if an 
  333.         error is detected -- on the assumption that you may have given 
  334.         an incorrect command.  
  335.         
  336.         Here is a list of possible error messages you might see 
  337.         displayed by the ADJRAM.EXE program and their probable cause 
  338.         (the numbers in parenthesis are explained in the next section): 
  339.  
  340.              Error -- could not read boot sector.  Error code xx (15)
  341.  
  342.         The program could not read the boot sector (logical sector 0) of 
  343.         the RAM disk.  An invalid drive letter was specified or the RAM 
  344.         disk has become corrupted.  In the latter case, reboot is 
  345.         recommended.  
  346.  
  347.              Error -- that drive is not the adjustable RAM disk. (15)
  348.  
  349.         An invalid drive letter was specified.  Use the letter that was 
  350.         reported by AMDISK when you booted the computer.  Make sure you 
  351.         used the correct command syntax.  A space must follow "ADJRAM".
  352.  
  353.              Error -- could not free environment block.  Error code xx 
  354.         (7)
  355.  
  356.         This error would indicate you have an incompatible version of 
  357.         MS-DOS.  The error codes are those returned by DOS function 49H.
  358.  
  359.              Error -- Invalid drive letter or memory disk is not loaded 
  360.         (15)
  361.  
  362.         ADJRAM reports this error if DOS returns an error code from 
  363.         function 36H (get free disk space).  Check your drive letter and 
  364.         command syntax.
  365.  
  366.              Error -- NOT enough room to do the shrink. (0)
  367.  
  368.         You do not have enough free space in the RAM disk to shrink it 
  369.         by the requested amount.  First erase some files from the RAM 
  370.         disk, then reenter you command.
  371.  
  372.              The disk is already that size!  Nothing to do. (0)
  373.  
  374.         You told ADJRAM to set the size to what it already is.  ADJRAM 
  375.         does nothing and exits.  Remember that your specified size is 
  376.         rounded up to the nearest multiple of 32K.
  377.  
  378.              Error -- could not modify memory block size.  Error code xx 
  379.         (8)
  380.  
  381.         This error occurs when expanding the RAM disk.  The program 
  382.         received an error code from DOS function 4AH (modify memory 
  383.         allocation) on the first new 32K memory block to be created.  It 
  384.         would indicate that you don't have enough free memory to expand 
  385.         the RAM disk at all.  It could also be caused by corrupted 
  386.         memory allocation, possibly caused by incompatibility with other 
  387.         memory resident programs.  Reboot is recommended in the latter 
  388.         case.
  389.  
  390.               Error -- could not allocate new memory block.  Error code 
  391.         xx (8) 
  392.  
  393.         This error is similar to the one above except that it occurs on 
  394.         the second and subsequent new 32K memory blocks when the program 
  395.         invokes DOS function 48H (allocate memory).  The program will 
  396.         attempt to keep going without expanding the disk any further.  
  397.         This condition is not well tested though, so to be safe, reboot 
  398.         is recommended.  
  399.  
  400.              Error -- could not allocate new memory block from EMM.  
  401.                       Error code xx (8) 
  402.  
  403.         This error is similar to the one above except that it occurs in 
  404.         conjunction with creating new 32K memory blocks in 
  405.         LOTUS/INTEL/Microsoft Expanded Memory.  The program will attempt 
  406.         to keep going without expanding the disk any further.  This 
  407.         condition is not well tested though, so to be safe, reboot is 
  408.         recommended.  
  409.  
  410.              Error -- could not write boot sector back.  Code: xx (15)
  411.  
  412.         This is most likely an internal program error.  The program got 
  413.         an error code from DOS interrupt 26H (write absolute disk 
  414.         sector).  Reboot is required.  
  415.  
  416.              Error -- could not free allocated memory block #xx.  Error 
  417.         code xx 
  418.         
  419.         This error occurs when shrinking the RAM disk.  The program got 
  420.         an error code from DOS function 49H (release memory).  Could be 
  421.         caused by an internal program bug, incompatible memory resident 
  422.         program, or incompatible version of DOS.  The program attempts 
  423.         to exit gracefully so that you can recover data files from the 
  424.         RAM disk, but you should reboot as soon as possible.  
  425.  
  426.              Error -- could not free EM pages for memory block #xx.  
  427.         Error code xx 
  428.         
  429.         This error occurs when shrinking the RAM disk.  The program got 
  430.         an error condition from the LOTUS/INTEL/Microsoft Expanded 
  431.         Memory Manager.  Could be caused by an internal program bug, 
  432.         incompatible memory resident program, or incompatible version of 
  433.         DOS.  The program attempts to exit gracefully so that you can 
  434.         recover data files from the RAM disk, but you should reboot as 
  435.         soon as possible.  
  436.  
  437.              Error -- Insufficient stack space to pack subdirectory 
  438.         xxxxxxxx.  Too many subdirectories.  Shrink abandoned. (8)
  439.  
  440.         This error occurs when shrinking the RAM disk.  The DeSmet C 
  441.         stack space was insufficient to handle the depth of 
  442.         subdirectories you have on your RAM disk.  The program attempts 
  443.         to exit gracefully without completing the shrink.  This 
  444.         condition has not been fully tested, so caution, your files may 
  445.         have been corrupted.  In the future, don't use so many 
  446.         subdirectories.  
  447.  
  448.              Error -- Expanded Memory Manager is not avaiable.
  449.                       Error code: xx (15)
  450.  
  451.         You specified the "/E" option, but the LOTUS/INTEL/Microsoft 
  452.         Expanded Memory Manager (EMM) is not loaded.  Load the EMM and 
  453.         try again.
  454.  
  455.              Error -- Expanded Memory Manager could not report page 
  456.         frame.  Error code: xx (8)
  457.  
  458.         The EMM was detected by ADJRAM, but the EMM reported an error 
  459.         when ADJRAM asked for the page frame segment address (EMM 
  460.         function 41H).  This could be caused by a corrupted EMM, or an 
  461.         incompatible version of the EMM (ADJRAM requires version 3.2 
  462.         compatibility), or possibly ADJRAM encountered a "busy" 
  463.         condition from the EMM.  Try again.  If it still fails, you'll 
  464.         have to stick with normal memory.  
  465.  
  466.         There are two other conditions which do not display an error 
  467.         message.  In these cases, the program simply displays the help 
  468.         message and exits:
  469.  
  470.              1.  Invalid drive letter specified.  Must be in range A 
  471.                  through I. (15)
  472.  
  473.              2.  Invalid size specified.  Must be in range 64 to 2016.  
  474.                  (1).  
  475.  
  476.         There are also a large number of possible errors that MS-DOS will 
  477.         display while you're working with the RAM disk.  Consult your 
  478.         DOS manual.  One message I'd like to point out.  If you see
  479.  
  480.              Bad File Allocation Table
  481.  
  482.         (or something similar) the RAM disk is probably corrupted.  
  483.         Carefully check your files.  If they are OK, copy them to a more 
  484.         permanent medium, such as floppy disk, then reboot.  
  485.         
  486.  
  487.         Using ADJRAM in Batch Files
  488.         ---------------------------
  489.         If an error occurs while running ADJRAM, it will return a DOS 
  490.         error code when it exits back to DOS.  The error codes returned 
  491.         are shown in parenthesis in the error message section above.  
  492.         These error codes can be used in a batch file via the DOS 
  493.         ERRORLEVEL subcommand.  See your DOS manual.  
  494.  
  495.         Some versions of MS-DOS (Z100 v2.21 for example) have a command 
  496.         which will cause error codes to be displayed.  It is: 
  497.  
  498.               XYZZY ON
  499.  
  500.  
  501.         Compatibility and Memory Usage
  502.         ------------------------------
  503.         The Adjustable RAM Disk falls into a class of programs known as 
  504.         Memory Resident programs.  Sidekick is one such program.  These 
  505.         programs are sometimes incompatible with one another.  It is 
  506.         impossible for me to test the Adjustable RAM disk in combination 
  507.         with every available memory resident program, so I'll apologize 
  508.         ahead of time -- some incompatibilities are almost certain to 
  509.         crop up.  
  510.  
  511.         Sometimes, changing the order inwhich the programs are loaded 
  512.         makes a difference.
  513.  
  514.         Generally, you should load all of your memory resident programs 
  515.         BEFORE you run ADJRAM.  (I know, every memory resident program 
  516.         wants to be loaded last, but please bear with me!)  You should 
  517.         do this to make the most efficient use of memory.  Here's why.  
  518.         When you expand the RAM disk, ADJRAM allocates 32K memory blocks 
  519.         using the DOS memory allocation functions.  Once that is done, 
  520.         any subsequent memory resident programs you load will generally 
  521.         get loaded above these new memory blocks.  When you later shrink 
  522.         the RAM disk, ADJRAM deallocates the memory blocks.  If you have 
  523.         loaded a memory resident program after expanding the RAM disk 
  524.         with ADJRAM, then "holes" in the memory allocation will be 
  525.         created when you later shrink the RAM disk.  These holes will 
  526.         generally not be usable for transient programs until you unload 
  527.         the memory resident program (which might not even have that 
  528.         capability).  
  529.         
  530.         You generally shrink the RAM disk because you want to make more 
  531.         memory available for other programs.  But it defeats this 
  532.         objective to load memory resident programs after expanding the 
  533.         RAM disk.  So...
  534.  
  535.              First load the memory resident programs, then use ADJRAM to 
  536.              expand your RAM disk.  
  537.  
  538.         The Adjustable RAM disk doesn't "steal" interrupts from the 
  539.         system, so expanding the RAM disk after loading programs that 
  540.         intercept interrupts, such as Sidekick, SHOULDN't cause any 
  541.         problems.
  542.  
  543.         If you encounter compatibility problems, please let me know at 
  544.         the address I'll give at the end of this document.  I'd like to 
  545.         know about them so I can fix them if possible.  Please be as 
  546.         complete as possible when you explain the problem.  What memory 
  547.         resident programs did you have loaded and in what order?  How 
  548.         much memory do you have in your computer?  What computer and 
  549.         operating system were you running?  Exactly what happened when 
  550.         it didn't work?  I won't guarantee that I can fix the problem, 
  551.         but I'll try.  
  552.         
  553.                  
  554.         Known Compatibility Problems
  555.         ----------------------------
  556.         When using ADJRAM with DoubleDOS, new memory blocks are created 
  557.         within whichever partition is active at the time you run ADJRAM.  
  558.         If you attempt to shrink the RAM disk to gain additional room in 
  559.         the first partition, you may find that you didn't gain any room 
  560.         in the first partition!  Instead, the room gained was in the 
  561.         second partition (because that's where the memory blocks were 
  562.         created).  
  563.  
  564.         Also, DoubleDOS doesn't know about ADJRAM creating new memory 
  565.         blocks.  This causes DoubleDOS to tell you there is more room in 
  566.         partitions than actually exists.  Use CHKDSK to find out how big 
  567.         your partitions really are.  In general, you should try to run 
  568.         ADJRAM before activating DoubleDOS, to avoid this problem.
  569.  
  570.         ADJRAM is somewhat incompatible with MARK/RELEASE.  You can't 
  571.         expand the RAM disk after you've run MARK, because when you run 
  572.         RELEASE, AMDISK won't know that some of its memory blocks have 
  573.         been freed.  As long as you expand before you run MARK for the 
  574.         first time, you should be OK.  I have not tried MARK/RELEASE in 
  575.         conjunction with ADJRAM, so there may be other problems as well.  
  576.         The Referee, being a program similar to MARK/RELEASE, will 
  577.         problably also have these problems.  
  578.                  
  579.         
  580.         Other Known Problems
  581.         --------------------
  582.         If you expand the RAM disk into all available memory, you will 
  583.         probably die.  You can't get enough room to run ADJRAM again so 
  584.         as to shrink it back down.  The program does not check to see if 
  585.         you're expanding the RAM disk into all free memory, so be 
  586.         careful.
  587.         
  588.         By the way, the coding fix to this problem is not as simple as 
  589.         you might think (my Z100 has 768K of user memory, not 640K.  
  590.         What about Expanded Memory?  etc.).  If someone can tell me a 
  591.         fullproof way to determine how much free memory exists, let me 
  592.         know.  
  593.         
  594.         Some programs, such as PC-WRITE have a "shell" or "hotkey" 
  595.         command that allows you to suspend the program, keeping it in 
  596.         memory, and execute other DOS commands.  You may be tempted to 
  597.         use this capability to increase or decrease the size of the RAM 
  598.         disk in the middle of running another program.  But be careful 
  599.         here.  Consider the following sequence of events:
  600.  
  601.              1.  You're running PC-WRITE, editing file C:MYFILE.DOC on 
  602.                  the RAM disk.
  603.  
  604.              2.  You use PC-WRITE's "shell" command to get the DOS 
  605.                  prompt.
  606.         
  607.              3.  You use ADJRAM to expand the size of disk C, the RAM 
  608.                  disk.  
  609.  
  610.              4.  You use the DOS EXIT command to go back into PC-WRITE.
  611.  
  612.              5.  Upon exiting PC-WRITE, you're horrified to learn that 
  613.                  it was unable to successfully save all your work in 
  614.                  C:MYFILE.DOC.
  615.  
  616.         The problem here is that ADJRAM told DOS that the "media has 
  617.         changed" on disk C.  But PC-WRITE had a file open on disk C!  
  618.         DOS can't properly close the file.  This sort of problem will 
  619.         generally occur with any program that has a "shell" command but 
  620.         fails to close all open files before executing the shell.  [By 
  621.         the way, I haven't actually checked that PC-WRITE does keep 
  622.         files open.  It may well be that there is no problem.  Indeed, 
  623.         it would surprise me to learn that PC-WRITE does have this 
  624.         problem.  PC-WRITE is a dynamite program!] 
  625.  
  626.         This kind of problem can also occur with certain memory resident 
  627.         programs that, in effect, give you a "shell" command from within 
  628.         any program.
  629.  
  630.         Remember that whenever you expand or shrink the RAM disk, you 
  631.         have, conceptually, removed the current "floppy disk" in the RAM 
  632.         drive, and replaced it with another "floppy disk" that just 
  633.         happens to have the same files as the one removed.  You wouldn't 
  634.         change a real floppy disk in the middle of editing a Wordstar 
  635.         file, so don't expand or shrink the RAM disk either.  
  636.  
  637.  
  638.         Planned Enhancements
  639.         --------------------
  640.         I'm planning on making the following enhancements at some time 
  641.         in the future: 
  642.         
  643.              1.  Fix the problem mentioned above about expanding into 
  644.                  all available memory.
  645.  
  646.              2.  Allow the initial RAM disk size to be specified at boot 
  647.                  time in the CONFIG.SYS file, like this
  648.  
  649.                  device = amdisk.dvd SIZE=32
  650.  
  651.         If you can think of other useful enhancements, let me know about 
  652.         them please.  
  653.  
  654.  
  655.         History
  656.         -------
  657.         This is the first version of ADJRAM to be released.  It was 
  658.         released to the public in September 1986.
  659.  
  660.  
  661.         Internals
  662.         ---------
  663.         This section is for anyone interested in the internal workings 
  664.         of the Adjustable RAM Disk.  It is not necessary to know this 
  665.         information to use the Adjustable RAM Disk, but it may be 
  666.         helpful for resolving compatibility problems.  This section is 
  667.         for advanced DOS programmers only.  
  668.  
  669.         AMDISK.DVD is a loadable device driver, just like VDISK or 
  670.         ANSI.SYS.  By itself, it is a complete 64K RAM disk.  A 64K 
  671.         "memory block" is allocated immediately after the AMDISK code.  
  672.         A Memory Block Table is maintained in logical sector 0 (the boot 
  673.         sector) of the RAM disk beginning at offset 1EH.  For each 
  674.         memory block, this table contains a seven byte entry as follows: 
  675.  
  676.              1.  A byte indicating the type of memory block.  0 means 
  677.                  the block is allocated in normal DOS memory.  1 means 
  678.                  the block is allocated in Expanded Memory.  
  679.         
  680.              2.  A word giving the starting paragraph number of the 
  681.                  memory block.  A paragraph of memory is simply 16 
  682.                  bytes, so this number is just the absolute memory 
  683.                  address shifted right by 4 bits.  All memory blocks 
  684.                  begin on an even paragraph boundary.  This word is zero 
  685.                  if there are no more memory blocks.  It is meaningless 
  686.                  for Expaned Memory blocks.
  687.  
  688.              3.  A word giving the size of the memory block in 512-byte 
  689.                  sectors.
  690.  
  691.              4.  A word giving the Expanded Memory handle for the memory 
  692.                  block.  Zero for normal memory blocks.
  693.  
  694.         Immediately after booting, there is exactly one 64K (128 sector) 
  695.         memory block in the Memory Block Table.
  696.  
  697.         Note:  Don't confuse the memory blocks defined here with those 
  698.                defined for DOS functions 48H thru 4AH.  To avoid 
  699.                confusion -- and though not strictly accurate -- I'll 
  700.                refer to DOS's memory blocks as "program segments".  
  701.         
  702.         The number of memory blocks allocated is stored in the media 
  703.         descriptor byte at offset 15H of the boot sector (and also in 
  704.         the first FAT entry).  Any time DOS requests a media code from 
  705.         the AMDISK device driver, it returns the number of memory blocks 
  706.         allocated.  In this way, any time that the RAM Disk has been 
  707.         shrunk or expanded, DOS will know that the "media has changed" 
  708.         and will rebuild its internal BPB tables.  This lets DOS know 
  709.         what the new size of the RAM disk is.  
  710.         
  711.         Upon startup of the ADJRAM program, DOS function 49H (release 
  712.         memory) is used to deallocate its own environment segment.  This 
  713.         doesn't seem to hurt a running program, and it is necessary to 
  714.         insure that this memory can be used later when the RAM disk is 
  715.         shrunk.
  716.  
  717.         At startup, the Expanded Memory version of ADJRAM tests whether 
  718.         the Expanded Memory Manager (EMM) is loaded by opening device 
  719.         "EMMXXXX0".  If the open fails, the EMM is not loaded.  If the 
  720.         open succeeds, then the output status is requested from the 
  721.         device using DOS function 44H (IOCTL).  If IOCTL reports a 
  722.         status of 0, then coincidentally a file named "EMMXXXX0" existed 
  723.         on the default disk, and the EMM is still not available.  If the 
  724.         EMM is not available, ADJRAM reports an error and exits.
  725.  
  726.         Also upon startup, ADJRAM checks that the specified drive letter 
  727.         corresponds to the AMDISK device.  The boot sector of the RAM 
  728.         disk contains the string "AMDISK" at offset 03H.  The boot 
  729.         sector is read using DOS interrupt 25H (absolute disk read).
  730.  
  731.         When the ADJRAM program increases the size of the RAM disk, it 
  732.         does so by allocating additional 32K (64 sector) memory blocks.  
  733.         Normal memory blocks are allocated in two ways:
  734.  
  735.              1.  If it is the first memory block to be created (in this 
  736.                  run of ADJRAM), then the memory block is allocated 
  737.                  using DOS function 4AH (modify memory allocation).  
  738.                  ADJRAM's own program segment is the one modified.  
  739.                  Hence, the first memory block overwrites the ADJRAM 
  740.                  program itself.
  741.  
  742.              2.  Additional memory blocks are allocated using DOS 
  743.                  function 48H (allocate memory).  
  744.  
  745.         In either case, an appropriate entry is made in the Memory Block 
  746.         Table, which is in the boot sector, for each new memory block.  
  747.         At the end of the program, the boot sector is written back out 
  748.         using DOS interrupt 26H (absolute disk write).  
  749.         
  750.         When ADJRAM exits normally, it uses DOS function 31H (terminate 
  751.         and stay resident) to permanently allocate the new memory 
  752.         blocks.  
  753.         
  754.         Expanded Memory blocks are allocated via EMM function 43H (Get 
  755.         handle and allocate memory).
  756.                  
  757.         When ADJRAM shrinks the RAM disk, it does these steps:
  758.                  
  759.              1.  It checks to insure there is sufficient free space in 
  760.                  the RAM disk to do the shrink.  
  761.              2.  The File Allocation Table (FAT) is read using DOS 
  762.                  interrupt 25H.  The first available cluster number is 
  763.                  determined.  
  764.              3.  The first sector of the directory is read in using DOS 
  765.                  interrupt 25H.
  766.              4.  For each file, any clusters located after the first 
  767.                  available cluster are moved down to the first available 
  768.                  cluster.  Then the next available cluster is 
  769.                  determined.  If the file is a subdirectory, then this  
  770.                  packing routine (steps 3 thru 5) is recursively called.  
  771.                  Clusters are moved in the RAM disk using DOS interrupts 
  772.                  25H and 26H.  As clusters are moved, the directory and 
  773.                  FAT in memory are updated.  
  774.              5.  Step 4 is repeated for each additional directory 
  775.                  sector.  Updated directory sectors are written back to 
  776.                  the disk using DOS interrupt 26H.
  777.              6.  The necessary number of memory blocks are deallocated, 
  778.                  either using DOS function 49H (release memory) or EMM 
  779.                  function 45H (release handle and memory).  The Memory 
  780.                  Block Table is updated accordingly.  Blocks are 
  781.                  deallocated in reverse of the order inwhich they are 
  782.                  created.  
  783.              7.  The updated FAT and boot sector are written back to the 
  784.                  disk using DOS interrupt 26H.  
  785.              8.  ADJRAM exits normally via DOS function 4CH (exit with 
  786.                  return code).
  787.  
  788.         An excellent book for understanding DOS memory allocation and 
  789.         disk structure is the "MsDOS Developer's Guide", written by the 
  790.         Waite Group and published by SAMS.  Another excellent book, 
  791.         which includes documentation on Expanded Memory, is "Advanced 
  792.         MS-DOS" by Ray Duncan.
  793.         
  794.         In the course of developing this program, I discovered a couple 
  795.         of interesting things about the DOS version 2 memory allocation 
  796.         functions (48H thru 4AH).  
  797.  
  798.              1.  Transient programs are always loaded after the last 
  799.                  allocated memory block, even if there is sufficient 
  800.                  memory available in "holes" below the last allocated 
  801.                  memory block.  Such holes could be created by loading a 
  802.                  memory resident program, such as Sidekick, and then 
  803.                  shrinking the RAM disk.
  804.  
  805.              2.  The allocate memory function (48H), on the otherhand, 
  806.                  will use holes if they exist and if they are large 
  807.                  enough to contain the requested block.
  808.  
  809.              3.  If a program modifies a DOS memory block (function 
  810.                  4AH), it becomes the "owner" of that block, even if it 
  811.                  didn't create the block in the first place.  When such 
  812.                  a program exits, the block will be automatically 
  813.                  deallocated by DOS unless the program exits via 
  814.                  terminate and stay resident.   This is why ADJRAM must 
  815.                  allocate memory blocks in fixed 32K increments.  
  816.                  Ideally, it should allocate exactly the requested size 
  817.                  and no more.  The DOS quirk described here prevents 
  818.                  that though.
  819.  
  820.         The source code for the Adjustable RAM Disk is included with the 
  821.         program.  AMDISK.DVD is coded in MASM; ADJRAM.EXE is coded in 
  822.         DeSmet C version 2.4.  Even though I've included the source 
  823.         code, I would nevertheless like to act as the clearinghouse for 
  824.         all future versions and modifications.  If you make a change to 
  825.         the program, or fix a bug, PLEASE let me know about it -- I may 
  826.         want to include the change in future versions. 
  827.         
  828.         If you modify the program, you agree to maintain my copyright.  
  829.         You should indicate that you've modified the program by changing 
  830.         the version number, for example "version 3.0A", or by putting 
  831.         some other distinguishing message in the signon of the program, 
  832.         for example "custom version by John Doe".  The rational for this 
  833.         is simple -- I don't won't to be blamed for your bug.  
  834.  
  835.         My address, as of September 1986 is:
  836.  
  837.              GARY CRAMBLITT
  838.              105 TENNESSEE RD
  839.              STEVENSVILLE, MD  21666
  840.  
  841.         Please do not telephone.  I'd like to receive your letter.
  842.  
  843.                        * * * *  END OF ADJRAM.DOC * * * *
  844.  
  845.